package com.drophair.jspwork.Servlet;

import com.drophair.jspwork.bean.Sqlgoods;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.sql.SQLException;

@WebServlet(name = "ClearCartServlet", value = "/ClearCartServlet")
public class ClearCartServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        Sqlgoods sqlgoods=new Sqlgoods();
        boolean getSign=false;
        try {
            getSign=sqlgoods.delAllCart();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
        if (getSign == true) {
            System.out.println("清空OK");
        }
        request.getRequestDispatcher("/common/cart.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
